O documento foi compilado no dia 2022-06-21 23:31:02 por Pamela Solano.
Ambos são algoritmos de aprendizado supervisionado;
Cada algoritmo aprende de differente forma;
Naive Bayes: usa o teorema de Bayes. Objetivo: Estimar a probabilidade de uma nova observação pertença a uma classe;
Naive Bayes: A nova observação é atribuída à classe com maior probabilidade;
Naive Bayes: Modelos treinados tem uma interpretação probabilistica;
Naive Bayes: Cada observação tem a probabilidade de pertencer a um grupo ou outro, fornecendo uma medida de incerteza na predição.
SVM: é mais geométrico. O algoritmo considera o hiperplano que divide as classes.
SVM: A posição e a direção desse hiperplano depende de vetores de suporte;
SVM: Os casos pertencem às classes que estão mais próximos das fronteiras definidos pelos suportes;
SVM: as probabilidades são complicadas de interpretar, mas a interpretação geométrica deixa mais claro as saídas do algoritmo;
SVM: O algoritmo particiona o espaço e classifica os casos observados considerando dita partição
SVM: é computacionalmente mais intenso do que naive Bayes.
SVM: Também é usado para problemas de regressão, isso nao será discutido aqui.
Ideia:
Pense no algoritmo de análise discriminante usa o teorema de Bayes mas sem redução de dimensão;
Predizer a probabilidade de uma observação pertencer a uma classe determinada (regressão logística);
A variável resposta (dependente) é categórica e as variáveis independentes podem ser categóricas ou quantitativas.
library(mlr)## Warning: package 'mlr' was built under R version 4.1.3
## Loading required package: ParamHelpers
## Warning: package 'ParamHelpers' was built under R version 4.1.3
## Warning message: 'mlr' is in 'maintenance-only' mode since July 2019.
## Future development will only happen in 'mlr3'
## (<https://mlr3.mlr-org.com>). Due to the focus on 'mlr3' there might be
## uncaught bugs meanwhile in {mlr} - please consider switching.
library(tidyverse)## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.6 v purrr 0.3.4
## v tibble 3.1.7 v dplyr 1.0.9
## v tidyr 1.2.0 v stringr 1.4.0
## v readr 2.1.2 v forcats 0.5.1
## Warning: package 'ggplot2' was built under R version 4.1.3
## Warning: package 'tibble' was built under R version 4.1.3
## Warning: package 'dplyr' was built under R version 4.1.3
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(mlbench)## Warning: package 'mlbench' was built under R version 4.1.3
data(HouseVotes84, package = "mlbench")
votesTib <- as_tibble(HouseVotes84)
votesTibmap_dbl(votesTib, ~sum(is.na(.)))## Class V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12
## 0 12 48 11 11 15 11 14 15 22 7 21 31
## V13 V14 V15 V16
## 25 17 28 104
votesUntidy <- gather(votesTib, "Variable", "Value", -Class)
ggplot(votesUntidy, aes(Class, fill = Value)) +
facet_wrap(~ Variable, scales = "free_y") +
geom_bar(position = "fill") +
theme_bw()votesTask <- makeClassifTask(data = votesTib, target = "Class")## Warning in makeTask(type = type, data = data, weights = weights, blocking =
## blocking, : Provided data is not a pure data.frame but from class tbl_df, hence
## it will be converted.
votesTask## Supervised task: votesTib
## Type: classif
## Target: Class
## Observations: 435
## Features:
## numerics factors ordered functionals
## 0 16 0 0
## Missings: TRUE
## Has weights: FALSE
## Has blocking: FALSE
## Has coordinates: FALSE
## Classes: 2
## democrat republican
## 267 168
## Positive class: democrat
bayes <- makeLearner("classif.naiveBayes")
bayes## Learner classif.naiveBayes from package e1071
## Type: classif
## Name: Naive Bayes; Short name: nbayes
## Class: classif.naiveBayes
## Properties: twoclass,multiclass,missings,numerics,factors,prob
## Predict-Type: response
## Hyperparameters:
bayesModel <- train(bayes, votesTask)
bayesModel## Model for learner.id=classif.naiveBayes; learner.class=classif.naiveBayes
## Trained on: task.id = votesTib; obs = 435; features = 16
## Hyperparameters:
politician <- tibble(V1 = "n", V2 = "n", V3 = "y", V4 = "n", V5 = "n",
V6 = "y", V7 = "y", V8 = "y", V9 = "y", V10 = "y",
V11 = "n", V12 = "y", V13 = "n", V14 = "n",
V15 = "y", V16 = "n")politicianPred <- predict(bayesModel, newdata = politician)## Warning in predict.WrappedModel(bayesModel, newdata = politician): Provided data
## for prediction is not a pure data.frame but from class tbl_df, hence it will be
## converted.
getPredictionResponse(politicianPred)## [1] democrat
## Levels: democrat republican
Figura 1
O algoritmo procurar um ótimo hiperplanos (linha sólida) que divide todo nosso espaço (dados);
um ótimo hiperplano é aquele que maximiza a margem em torno de si (linhas pontilhadas);
A margem é a region ao redor do hiperplano que toca o menor número de casos;
Vetores de suporte são os círculos duplos.
SVM.
Figura 2
A posição do hiperplano é dependente da poição do vetor de suporte;
Sensível: Se mover um vetor de suporte então o hiperplano muda sua posição inicial (linhas pontilhadas) para uma nova posição (as duas figuras no topo);
Mover um vetor que não é um vetor de suporte nao tem impacto no hiperplano (as duas figuras abaixo)
SVM.
Figura 3
Não linearidade: As classes não são linearmente separáveis
O algoritmo SVM incorporda uma nova dimensão. A terceira dimensão permite que os dados sejam linearmente separáveis
A terceira dimensão é projetado para acima das duas dimensões criando uma curva de limite de decisão.
SVM.
library(kernlab)## Warning: package 'kernlab' was built under R version 4.1.3
##
## Attaching package: 'kernlab'
## The following object is masked from 'package:purrr':
##
## cross
## The following object is masked from 'package:ggplot2':
##
## alpha
data(spam, package = "kernlab")
spamTib <- as_tibble(spam)
spamTibspamTask <- makeClassifTask(data = spamTib, target = "type")## Warning in makeTask(type = type, data = data, weights = weights, blocking =
## blocking, : Provided data is not a pure data.frame but from class tbl_df, hence
## it will be converted.
svm <- makeLearner("classif.svm")getParamSet("classif.svm")## Type len Def
## type discrete - C-classifica...
## cost numeric - 1
## nu numeric - 0.5
## class.weights numericvector <NA> -
## kernel discrete - radial
## degree integer - 3
## coef0 numeric - 0
## gamma numeric - -
## cachesize numeric - 40
## tolerance numeric - 0.001
## shrinking logical - TRUE
## cross integer - 0
## fitted logical - TRUE
## scale logicalvector <NA> TRUE
## Constr Req Tunable Trafo
## type C-classification,nu-classification - TRUE -
## cost 0 to Inf Y TRUE -
## nu -Inf to Inf Y TRUE -
## class.weights 0 to Inf - TRUE -
## kernel linear,polynomial,radial,sigmoid - TRUE -
## degree 1 to Inf Y TRUE -
## coef0 -Inf to Inf Y TRUE -
## gamma 0 to Inf Y TRUE -
## cachesize -Inf to Inf - TRUE -
## tolerance 0 to Inf - TRUE -
## shrinking - - TRUE -
## cross 0 to Inf - FALSE -
## fitted - - FALSE -
## scale - - TRUE -
getParamSet("classif.svm")$pars$kernel$values## $linear
## [1] "linear"
##
## $polynomial
## [1] "polynomial"
##
## $radial
## [1] "radial"
##
## $sigmoid
## [1] "sigmoid"
Kernel
Cost
Degree
Gamma
kernels <- c("polynomial", "radial", "sigmoid")randSearch <- makeTuneControlRandom(maxit = 20)
randSearch## Tune control: TuneControlRandom
## Same resampling instance: TRUE
## Imputation value: <worst>
## Start: <NULL>
## Budget: 20
## Tune threshold: FALSE
## Further arguments: maxit=20
cvForTuning <- makeResampleDesc("Holdout", split = 2/3)
cvForTuning## Resample description: holdout with 0.67 split rate.
## Predict: test
## Stratification: FALSE
svmParamSpace <- makeParamSet(
makeDiscreteParam("kernel", values = "linear"),
makeNumericParam("cost", lower = 0.1, upper = 100))library(parallelMap)## Warning: package 'parallelMap' was built under R version 4.1.3
library(parallel)
parallelStartSocket(cpus = detectCores())## Starting parallelization in mode=socket with cpus=8.
tunedSvmPars <- tuneParams("classif.svm", task = spamTask,
resampling = cvForTuning,
par.set = svmParamSpace,
control = randSearch)## [Tune] Started tuning learner classif.svm for parameter set:
## Type len Def Constr Req Tunable Trafo
## kernel discrete - - linear - TRUE -
## cost numeric - - 0.1 to 100 - TRUE -
## With control class: TuneControlRandom
## Imputation value: 1
## Exporting objects to slaves for mode socket: .mlr.slave.options
## Mapping in parallel: mode = socket; level = mlr.tuneParams; cpus = 8; elements = 20.
## [Tune] Result: kernel=linear; cost=75 : mmce.test.mean=0.0573664
parallelStop()## Stopped parallelization. All cleaned up.
tunedSvmPars%>%str## List of 7
## $ learner :List of 16
## ..$ id : chr "classif.svm"
## ..$ type : chr "classif"
## ..$ package : chr "e1071"
## ..$ properties : chr [1:6] "twoclass" "multiclass" "numerics" "factors" ...
## ..$ par.set :List of 2
## .. ..$ pars :List of 14
## .. .. ..$ type :List of 15
## .. .. .. ..$ id : chr "type"
## .. .. .. ..$ type : chr "discrete"
## .. .. .. ..$ len : int 1
## .. .. .. ..$ lower : NULL
## .. .. .. ..$ upper : NULL
## .. .. .. ..$ values :List of 2
## .. .. .. .. ..$ C-classification : chr "C-classification"
## .. .. .. .. ..$ nu-classification: chr "nu-classification"
## .. .. .. ..$ cnames : NULL
## .. .. .. ..$ allow.inf : logi FALSE
## .. .. .. ..$ has.default : logi TRUE
## .. .. .. ..$ default : chr "C-classification"
## .. .. .. ..$ trafo : NULL
## .. .. .. ..$ requires : NULL
## .. .. .. ..$ tunable : logi TRUE
## .. .. .. ..$ special.vals: list()
## .. .. .. ..$ when : chr "train"
## .. .. .. ..- attr(*, "class")= chr [1:2] "LearnerParam" "Param"
## .. .. ..$ cost :List of 15
## .. .. .. ..$ id : chr "cost"
## .. .. .. ..$ type : chr "numeric"
## .. .. .. ..$ len : int 1
## .. .. .. ..$ lower : num 0
## .. .. .. ..$ upper : num Inf
## .. .. .. ..$ values : NULL
## .. .. .. ..$ cnames : NULL
## .. .. .. ..$ allow.inf : logi FALSE
## .. .. .. ..$ has.default : logi TRUE
## .. .. .. ..$ default : num 1
## .. .. .. ..$ trafo : NULL
## .. .. .. ..$ requires : language type == "C-classification"
## .. .. .. ..$ tunable : logi TRUE
## .. .. .. ..$ special.vals: list()
## .. .. .. ..$ when : chr "train"
## .. .. .. ..- attr(*, "class")= chr [1:2] "LearnerParam" "Param"
## .. .. ..$ nu :List of 15
## .. .. .. ..$ id : chr "nu"
## .. .. .. ..$ type : chr "numeric"
## .. .. .. ..$ len : int 1
## .. .. .. ..$ lower : num -Inf
## .. .. .. ..$ upper : num Inf
## .. .. .. ..$ values : NULL
## .. .. .. ..$ cnames : NULL
## .. .. .. ..$ allow.inf : logi FALSE
## .. .. .. ..$ has.default : logi TRUE
## .. .. .. ..$ default : num 0.5
## .. .. .. ..$ trafo : NULL
## .. .. .. ..$ requires : language type == "nu-classification"
## .. .. .. ..$ tunable : logi TRUE
## .. .. .. ..$ special.vals: list()
## .. .. .. ..$ when : chr "train"
## .. .. .. ..- attr(*, "class")= chr [1:2] "LearnerParam" "Param"
## .. .. ..$ class.weights:List of 15
## .. .. .. ..$ id : chr "class.weights"
## .. .. .. ..$ type : chr "numericvector"
## .. .. .. ..$ len : int NA
## .. .. .. ..$ lower : num 0
## .. .. .. ..$ upper : num Inf
## .. .. .. ..$ values : NULL
## .. .. .. ..$ cnames : NULL
## .. .. .. ..$ allow.inf : logi FALSE
## .. .. .. ..$ has.default : logi FALSE
## .. .. .. ..$ default : NULL
## .. .. .. ..$ trafo : NULL
## .. .. .. ..$ requires : NULL
## .. .. .. ..$ tunable : logi TRUE
## .. .. .. ..$ special.vals: list()
## .. .. .. ..$ when : chr "train"
## .. .. .. ..- attr(*, "class")= chr [1:2] "LearnerParam" "Param"
## .. .. ..$ kernel :List of 15
## .. .. .. ..$ id : chr "kernel"
## .. .. .. ..$ type : chr "discrete"
## .. .. .. ..$ len : int 1
## .. .. .. ..$ lower : NULL
## .. .. .. ..$ upper : NULL
## .. .. .. ..$ values :List of 4
## .. .. .. .. ..$ linear : chr "linear"
## .. .. .. .. ..$ polynomial: chr "polynomial"
## .. .. .. .. ..$ radial : chr "radial"
## .. .. .. .. ..$ sigmoid : chr "sigmoid"
## .. .. .. ..$ cnames : NULL
## .. .. .. ..$ allow.inf : logi FALSE
## .. .. .. ..$ has.default : logi TRUE
## .. .. .. ..$ default : chr "radial"
## .. .. .. ..$ trafo : NULL
## .. .. .. ..$ requires : NULL
## .. .. .. ..$ tunable : logi TRUE
## .. .. .. ..$ special.vals: list()
## .. .. .. ..$ when : chr "train"
## .. .. .. ..- attr(*, "class")= chr [1:2] "LearnerParam" "Param"
## .. .. ..$ degree :List of 15
## .. .. .. ..$ id : chr "degree"
## .. .. .. ..$ type : chr "integer"
## .. .. .. ..$ len : int 1
## .. .. .. ..$ lower : int 1
## .. .. .. ..$ upper : num Inf
## .. .. .. ..$ values : NULL
## .. .. .. ..$ cnames : NULL
## .. .. .. ..$ allow.inf : logi FALSE
## .. .. .. ..$ has.default : logi TRUE
## .. .. .. ..$ default : int 3
## .. .. .. ..$ trafo : NULL
## .. .. .. ..$ requires : language kernel == "polynomial"
## .. .. .. ..$ tunable : logi TRUE
## .. .. .. ..$ special.vals: list()
## .. .. .. ..$ when : chr "train"
## .. .. .. ..- attr(*, "class")= chr [1:2] "LearnerParam" "Param"
## .. .. ..$ coef0 :List of 15
## .. .. .. ..$ id : chr "coef0"
## .. .. .. ..$ type : chr "numeric"
## .. .. .. ..$ len : int 1
## .. .. .. ..$ lower : num -Inf
## .. .. .. ..$ upper : num Inf
## .. .. .. ..$ values : NULL
## .. .. .. ..$ cnames : NULL
## .. .. .. ..$ allow.inf : logi FALSE
## .. .. .. ..$ has.default : logi TRUE
## .. .. .. ..$ default : num 0
## .. .. .. ..$ trafo : NULL
## .. .. .. ..$ requires : language kernel == "polynomial" || kernel == "sigmoid"
## .. .. .. ..$ tunable : logi TRUE
## .. .. .. ..$ special.vals: list()
## .. .. .. ..$ when : chr "train"
## .. .. .. ..- attr(*, "class")= chr [1:2] "LearnerParam" "Param"
## .. .. ..$ gamma :List of 15
## .. .. .. ..$ id : chr "gamma"
## .. .. .. ..$ type : chr "numeric"
## .. .. .. ..$ len : int 1
## .. .. .. ..$ lower : num 0
## .. .. .. ..$ upper : num Inf
## .. .. .. ..$ values : NULL
## .. .. .. ..$ cnames : NULL
## .. .. .. ..$ allow.inf : logi FALSE
## .. .. .. ..$ has.default : logi FALSE
## .. .. .. ..$ default : NULL
## .. .. .. ..$ trafo : NULL
## .. .. .. ..$ requires : language kernel != "linear"
## .. .. .. ..$ tunable : logi TRUE
## .. .. .. ..$ special.vals: list()
## .. .. .. ..$ when : chr "train"
## .. .. .. ..- attr(*, "class")= chr [1:2] "LearnerParam" "Param"
## .. .. ..$ cachesize :List of 15
## .. .. .. ..$ id : chr "cachesize"
## .. .. .. ..$ type : chr "numeric"
## .. .. .. ..$ len : int 1
## .. .. .. ..$ lower : num -Inf
## .. .. .. ..$ upper : num Inf
## .. .. .. ..$ values : NULL
## .. .. .. ..$ cnames : NULL
## .. .. .. ..$ allow.inf : logi FALSE
## .. .. .. ..$ has.default : logi TRUE
## .. .. .. ..$ default : int 40
## .. .. .. ..$ trafo : NULL
## .. .. .. ..$ requires : NULL
## .. .. .. ..$ tunable : logi TRUE
## .. .. .. ..$ special.vals: list()
## .. .. .. ..$ when : chr "train"
## .. .. .. ..- attr(*, "class")= chr [1:2] "LearnerParam" "Param"
## .. .. ..$ tolerance :List of 15
## .. .. .. ..$ id : chr "tolerance"
## .. .. .. ..$ type : chr "numeric"
## .. .. .. ..$ len : int 1
## .. .. .. ..$ lower : num 0
## .. .. .. ..$ upper : num Inf
## .. .. .. ..$ values : NULL
## .. .. .. ..$ cnames : NULL
## .. .. .. ..$ allow.inf : logi FALSE
## .. .. .. ..$ has.default : logi TRUE
## .. .. .. ..$ default : num 0.001
## .. .. .. ..$ trafo : NULL
## .. .. .. ..$ requires : NULL
## .. .. .. ..$ tunable : logi TRUE
## .. .. .. ..$ special.vals: list()
## .. .. .. ..$ when : chr "train"
## .. .. .. ..- attr(*, "class")= chr [1:2] "LearnerParam" "Param"
## .. .. ..$ shrinking :List of 15
## .. .. .. ..$ id : chr "shrinking"
## .. .. .. ..$ type : chr "logical"
## .. .. .. ..$ len : int 1
## .. .. .. ..$ lower : NULL
## .. .. .. ..$ upper : NULL
## .. .. .. ..$ values :List of 2
## .. .. .. .. ..$ TRUE : logi TRUE
## .. .. .. .. ..$ FALSE: logi FALSE
## .. .. .. ..$ cnames : NULL
## .. .. .. ..$ allow.inf : logi FALSE
## .. .. .. ..$ has.default : logi TRUE
## .. .. .. ..$ default : logi TRUE
## .. .. .. ..$ trafo : NULL
## .. .. .. ..$ requires : NULL
## .. .. .. ..$ tunable : logi TRUE
## .. .. .. ..$ special.vals: list()
## .. .. .. ..$ when : chr "train"
## .. .. .. ..- attr(*, "class")= chr [1:2] "LearnerParam" "Param"
## .. .. ..$ cross :List of 15
## .. .. .. ..$ id : chr "cross"
## .. .. .. ..$ type : chr "integer"
## .. .. .. ..$ len : int 1
## .. .. .. ..$ lower : int 0
## .. .. .. ..$ upper : num Inf
## .. .. .. ..$ values : NULL
## .. .. .. ..$ cnames : NULL
## .. .. .. ..$ allow.inf : logi FALSE
## .. .. .. ..$ has.default : logi TRUE
## .. .. .. ..$ default : int 0
## .. .. .. ..$ trafo : NULL
## .. .. .. ..$ requires : NULL
## .. .. .. ..$ tunable : logi FALSE
## .. .. .. ..$ special.vals: list()
## .. .. .. ..$ when : chr "train"
## .. .. .. ..- attr(*, "class")= chr [1:2] "LearnerParam" "Param"
## .. .. ..$ fitted :List of 15
## .. .. .. ..$ id : chr "fitted"
## .. .. .. ..$ type : chr "logical"
## .. .. .. ..$ len : int 1
## .. .. .. ..$ lower : NULL
## .. .. .. ..$ upper : NULL
## .. .. .. ..$ values :List of 2
## .. .. .. .. ..$ TRUE : logi TRUE
## .. .. .. .. ..$ FALSE: logi FALSE
## .. .. .. ..$ cnames : NULL
## .. .. .. ..$ allow.inf : logi FALSE
## .. .. .. ..$ has.default : logi TRUE
## .. .. .. ..$ default : logi TRUE
## .. .. .. ..$ trafo : NULL
## .. .. .. ..$ requires : NULL
## .. .. .. ..$ tunable : logi FALSE
## .. .. .. ..$ special.vals: list()
## .. .. .. ..$ when : chr "train"
## .. .. .. ..- attr(*, "class")= chr [1:2] "LearnerParam" "Param"
## .. .. ..$ scale :List of 15
## .. .. .. ..$ id : chr "scale"
## .. .. .. ..$ type : chr "logicalvector"
## .. .. .. ..$ len : int NA
## .. .. .. ..$ lower : NULL
## .. .. .. ..$ upper : NULL
## .. .. .. ..$ values :List of 2
## .. .. .. .. ..$ TRUE : logi TRUE
## .. .. .. .. ..$ FALSE: logi FALSE
## .. .. .. ..$ cnames : NULL
## .. .. .. ..$ allow.inf : logi FALSE
## .. .. .. ..$ has.default : logi TRUE
## .. .. .. ..$ default : logi TRUE
## .. .. .. ..$ trafo : NULL
## .. .. .. ..$ requires : NULL
## .. .. .. ..$ tunable : logi TRUE
## .. .. .. ..$ special.vals: list()
## .. .. .. ..$ when : chr "train"
## .. .. .. ..- attr(*, "class")= chr [1:2] "LearnerParam" "Param"
## .. ..$ forbidden: NULL
## .. ..- attr(*, "class")= chr [1:2] "LearnerParamSet" "ParamSet"
## ..$ par.vals : Named list()
## ..$ predict.type : chr "response"
## ..$ cache : logi FALSE
## ..$ name : chr "Support Vector Machines (libsvm)"
## ..$ short.name : chr "svm"
## ..$ note : chr ""
## ..$ callees : chr "svm"
## ..$ help.list :List of 14
## .. ..$ scale : chr "Argument of: e1071::svm\n\nA logical vector indicating the variables to be scaled. If scale is of length 1, the"| __truncated__
## .. ..$ type : chr "Argument of: e1071::svm\n\nsvm can be used as a classification machine, as a regression machine, or for novelty"| __truncated__
## .. ..$ kernel : chr "Argument of: e1071::svm\n\nthe kernel used in training and predicting. You might consider changing some of the "| __truncated__
## .. ..$ degree : chr "Argument of: e1071::svm\n\nparameter needed for kernel of type polynomial (default: 3)"
## .. ..$ gamma : chr "Argument of: e1071::svm\n\nparameter needed for all kernels except linear (default: 1/(data dimension))"
## .. ..$ coef0 : chr "Argument of: e1071::svm\n\nparameter needed for kernels of type polynomial and sigmoid (default: 0)"
## .. ..$ cost : chr "Argument of: e1071::svm\n\ncost of constraints violation (default: 1)—it is the ‘C’-constant of the regularizat"| __truncated__
## .. ..$ nu : chr "Argument of: e1071::svm\n\nparameter needed for nu-classification, nu-regression, and one-classification"
## .. ..$ class.weights: chr "Argument of: e1071::svm\n\na named vector of weights for the different classes, used for asymmetric class sizes"| __truncated__
## .. ..$ cachesize : chr "Argument of: e1071::svm\n\ncache memory in MB (default 40)"
## .. ..$ tolerance : chr "Argument of: e1071::svm\n\ntolerance of termination criterion (default: 0.001)"
## .. ..$ shrinking : chr "Argument of: e1071::svm\n\noption whether to use the shrinking-heuristics (default: TRUE)"
## .. ..$ cross : chr "Argument of: e1071::svm\n\nif a integer value k>0 is specified, a k-fold cross validation on the training data "| __truncated__
## .. ..$ fitted : chr "Argument of: e1071::svm\n\nlogical indicating whether the fitted values should be computed and included in the "| __truncated__
## ..$ class.weights.param : chr "class.weights"
## ..$ config : list()
## ..$ fix.factors.prediction: logi FALSE
## ..- attr(*, "class")= chr [1:4] "classif.svm" "RLearnerClassif" "RLearner" "Learner"
## $ control :List of 8
## ..$ same.resampling.instance: logi TRUE
## ..$ impute.val : num 1
## ..$ tune.threshold : logi FALSE
## ..$ tune.threshold.args : list()
## ..$ log.fun :function (learner, task, resampling, measures, par.set, control, opt.path,
## dob, x, y, remove.nas, stage, prev.stage)
## ..$ final.dw.perc : NULL
## ..$ extra.args :List of 1
## .. ..$ maxit: int 20
## ..$ budget : int 20
## ..- attr(*, "class")= chr [1:3] "TuneControlRandom" "TuneControl" "OptControl"
## $ x :List of 2
## ..$ kernel: chr "linear"
## ..$ cost : num 75
## $ y : Named num 0.0574
## ..- attr(*, "names")= chr "mmce.test.mean"
## $ resampling:List of 5
## ..$ desc :List of 7
## .. ..$ split : num 0.667
## .. ..$ id : chr "holdout"
## .. ..$ iters : int 1
## .. ..$ predict : chr "test"
## .. ..$ stratify : logi FALSE
## .. ..$ fixed : logi FALSE
## .. ..$ blocking.cv: logi FALSE
## .. ..- attr(*, "class")= chr [1:2] "HoldoutDesc" "ResampleDesc"
## ..$ size : int 4601
## ..$ train.inds:List of 1
## .. ..$ : int [1:3067] 4073 2464 214 3401 3962 1393 1226 4244 4584 1345 ...
## ..$ test.inds :List of 1
## .. ..$ : int [1:1534] 1800 2473 1304 4184 346 2588 367 2044 1786 2482 ...
## ..$ group : Factor w/ 0 levels:
## ..- attr(*, "class")= chr "ResampleInstance"
## $ threshold : NULL
## $ opt.path :List of 5
## ..$ par.set :List of 2
## .. ..$ pars :List of 2
## .. .. ..$ kernel:List of 14
## .. .. .. ..$ id : chr "kernel"
## .. .. .. ..$ type : chr "discrete"
## .. .. .. ..$ len : int 1
## .. .. .. ..$ lower : NULL
## .. .. .. ..$ upper : NULL
## .. .. .. ..$ values :List of 1
## .. .. .. .. ..$ linear: chr "linear"
## .. .. .. ..$ cnames : NULL
## .. .. .. ..$ allow.inf : logi FALSE
## .. .. .. ..$ has.default : logi FALSE
## .. .. .. ..$ default : NULL
## .. .. .. ..$ trafo : NULL
## .. .. .. ..$ requires : NULL
## .. .. .. ..$ tunable : logi TRUE
## .. .. .. ..$ special.vals: list()
## .. .. .. ..- attr(*, "class")= chr "Param"
## .. .. ..$ cost :List of 14
## .. .. .. ..$ id : chr "cost"
## .. .. .. ..$ type : chr "numeric"
## .. .. .. ..$ len : int 1
## .. .. .. ..$ lower : num 0.1
## .. .. .. ..$ upper : num 100
## .. .. .. ..$ values : NULL
## .. .. .. ..$ cnames : NULL
## .. .. .. ..$ allow.inf : logi FALSE
## .. .. .. ..$ has.default : logi FALSE
## .. .. .. ..$ default : NULL
## .. .. .. ..$ trafo : NULL
## .. .. .. ..$ requires : NULL
## .. .. .. ..$ tunable : logi TRUE
## .. .. .. ..$ special.vals: list()
## .. .. .. ..- attr(*, "class")= chr "Param"
## .. ..$ forbidden: NULL
## .. ..- attr(*, "class")= chr "ParamSet"
## ..$ y.names : chr "mmce.test.mean"
## ..$ minimize : Named logi TRUE
## .. ..- attr(*, "names")= chr "mmce.test.mean"
## ..$ add.transformed.x: logi FALSE
## ..$ env :<environment: 0x000000002e3fcf50>
## ..- attr(*, "class")= chr [1:2] "OptPathDF" "OptPath"
## - attr(*, "class")= chr [1:2] "TuneResult" "OptResult"
Naive Bayes e SVM são algoritmos de aprendizagem supervisionados;
Naive Bayes é baseado na teoria de probabilidades;
SVM procura o hiperplano ótimo;
Naive Bayes usa preditores cat e cont, SVM só usa preditores cont;
SVM é muito mais intenso computacionalmente do que Naive Bayes;
SVM usa funções kernel para encontrar fronteiras de decisões lineares;
SVM é sensível aos valores dos hiperparâmetros.